#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cstring>
#include <math.h>
using namespace std;
int MyStrcmp(char* a,char*b)
{
	int alen = strlen(a);
	int blen = strlen(b);
	if (alen < blen)
	{
		return -1;
	}
	else if (alen > blen)
	{
		return 1;
	}
	else
	{
		while (*(a) != '\0' || *(b) != '\0')
		{
			if (*(a) > *(b))
				return 1;
			else if (*(a) < *(b))
				return -1;
			else
			{
				a++;
				b++;
			}
		}
		return 0;
	}
}
int main() 
{
	int n;
	char maxVotes[2000]="0";
	char Votes[2000]="0";
	int maxPeo=1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s", Votes);
		if (MyStrcmp(maxVotes, Votes)<0)
		{
			maxPeo = i + 1;
			strcpy(maxVotes, Votes);
		}
	}
	printf("%d\n%s",maxPeo, maxVotes);
	return 0;
}